<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/12 0012
 * Time: 上午 11:00
 */
include "config.php";
include "status.php";

if($_SERVER["REQUEST_METHOD"]!="POST"){
    print_r(json_encode(status::$r_0));
    return ;
}
if (isset($_REQUEST["utel"])&&isset($_REQUEST["upwd"])){

    $UTEL=$_REQUEST["utel"];
    $UPWD=$_REQUEST["upwd"];


    $sql="SELECT `u_id`,`u_tel` FROM userinfo WHERE u_tel=? AND u_pwd=? ;";
    $stmt=$conn->prepare($sql);//预处理
    $stmt->bind_param("ss",$UTEL,$UPWD);
    $stmt->execute();//执行
    $resultArr=$stmt->get_result();//取结果
    if ($resultArr->num_rows>=1){
        Status::$login_success["data"]=$resultArr->fetch_assoc();//把数据拿到客户端  fetch_assoc()把一条数据转化成一个对象
        print_r(json_encode(status::$login_success));
    }else{
        print_r(json_encode(status::$login_error));
    }

    $stmt->close();
    $conn->close();
}else{
    print_r(json_encode(status::$login_1));
}